package vg.main;

import com.google.common.collect.Lists;
import vg.modules.attribute_panel.AttributePlugin;
import vg.modules.backlight.PathSelectingPlugin;
import vg.modules.desktop.DesktopPlugin;
import vg.modules.exporters.GraphMLExporterPlugin;
import vg.modules.filter.FilterPlugin;
import vg.modules.graph_comparison.GraphComparisonPlugin;
import vg.modules.graph_settings.GraphSettingsPlugin;
import vg.modules.help.about.AboutPlugin;
import vg.modules.layout.GraphLayoutPlugin;
import vg.modules.minimap.MiniMapPlugin;
import vg.modules.navigator.NavigatorPlugin;
import vg.modules.opener.GraphOpenerPlugin;
import vg.modules.util_plugins.LookAndFeelChanger;
import vg.modules.util_plugins.PanningButtonPlugin;
import vg.modules.util_plugins.UndoRedoButtonPlugin;
import vg.modules.zoom.ZoomPlugin;
import vg.services.main_manager.VGMainService;
import vg.services.main_manager.VGMainServiceHelper;
import vg.services.plugin_manager.interfaces.IPlugin;

import javax.swing.*;
import java.util.List;

/**
 * Enter point.
 *
 * @author Timur Zolotuhin (e-mail: tzolotuhin@gmail.com)
 */
public class Main {
	public static void main(String[] args) {
        // execute initial preparations
        VGMainService.executeInitialPreparations(args);

        VGMainServiceHelper.logger.printInfo("AppInstanceId = " + VGMainServiceHelper.CmdLineOptions.appInstanceIdOption.getInstanceId());

        VGMainServiceHelper.logger.enableDebugMessage(true);

        final List<IPlugin> plugins = Lists.newArrayList();
        //plugins.add(new ConnectorPlugin());
        plugins.add(new GraphOpenerPlugin());
        plugins.add(new GraphLayoutPlugin());
        plugins.add(new DesktopPlugin());
        plugins.add(new FilterPlugin());
        plugins.add(new UndoRedoButtonPlugin());
        plugins.add(new GraphSettingsPlugin());
        plugins.add(new LookAndFeelChanger());
        //plugins.add(new NotepadPlugin());
        plugins.add(new PathSelectingPlugin());
        plugins.add(new AttributePlugin());
        plugins.add(new ZoomPlugin());
        plugins.add(new MiniMapPlugin());
        plugins.add(new PanningButtonPlugin());
        plugins.add(new AboutPlugin());
        plugins.add(new GraphComparisonPlugin());
        plugins.add(new GraphMLExporterPlugin());
        plugins.add(new NavigatorPlugin());

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                for (final IPlugin plugin : plugins) {
                    try {
                        plugin.install();
                    } catch (Throwable ex) {
                        System.err.println(ex.getMessage());
                    }
                }
            }
        });
	}
}
